<?php
include '../meihe/common.php';
$id = $_SERVER['QUERY_STRING'];
$row = $DB->get_row("SELECT * FROM meihe_report WHERE uid='{$id}' limit 1");
if ($row) {
    $t_url = $row['url'];
    if (in_array($t_url, explode('|', $conf['lhbamd']))) {
        sysmsg('<h3>当前域名已被拉黑，无法查看！</h3>');
        exit(0);
    }
    $title = '正在为你打开网页中';
    if (!(strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== !1)) {
        if (!(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== !1)) {
            $fhfwfs = '其它方式';
            $url_arr = parse_url($t_url);
            $domain = $url_arr['host'];
            $rowhy = $DB->get_row('SELECT * FROM meihe_list WHERE domain=\'' . $domain . '\' limit 1');
            if (empty($rowhy)) {
                $rowhy = $DB->get_row('SELECT * FROM meihe_list WHERE domain=\'' . get_host($domain) . '\' and `fhy`=\'2\' limit 1');
            }
            if ($rowhy['type'] != 0x1) {
                $gjbq = $conf['tztcgg'];
                if ($rowhy['type'] != 0x1) {
                    $thtime = date('Y-m-d', strtotime('-1 day')) . ' 00:00:00';
                    $meihepvr = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and click_time>=\'' . $thtime . '\'');
                    if ($meihepvr > $conf['day_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 今日访问次数已上限！</h3>');
                        exit(0);
                    }
                    $yesterday_time = date('Y-m-d', strtotime('-1 month')) . ' 00:00:00';
                    $meihepvy = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and and  click_time>=\'' . $yesterday_time . '\'');
                    if ($meihepvy > $conf['month_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 本月访问次数已上限！</h3>');
                        exit(0);
                    } else {
                        if ($rowhy['type'] == 0x2) {
                            sysmsg('<h3>当前网址' . $t_url . ' 已被拉黑无法访问！</h3>');
                            exit(0);
                        } else {
                        }
                    }
                } else {
                }
            } else {
                if ($rowhy['type'] != 0x1) {
                    $thtime = date('Y-m-d', strtotime('-1 day')) . ' 00:00:00';
                    $meihepvr = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and click_time>=\'' . $thtime . '\'');
                    if ($meihepvr > $conf['day_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 今日访问次数已上限！</h3>');
                        exit(0);
                    }
                    $yesterday_time = date('Y-m-d', strtotime('-1 month')) . ' 00:00:00';
                    $meihepvy = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and and  click_time>=\'' . $yesterday_time . '\'');
                    if ($meihepvy > $conf['month_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 本月访问次数已上限！</h3>');
                        exit(0);
                    } else {
                        if ($rowhy['type'] == 0x2) {
                            sysmsg('<h3>当前网址' . $t_url . ' 已被拉黑无法访问！</h3>');
                            exit(0);
                        } else {
                        }
                    }
                } else {
                }
            }
        } else {
            $fhfwfs = '微信方式';
            $url_arr = parse_url($t_url);
            $domain = $url_arr['host'];
            $rowhy = $DB->get_row('SELECT * FROM meihe_list WHERE domain=\'' . $domain . '\' limit 1');
            if (empty($rowhy)) {
                $rowhy = $DB->get_row('SELECT * FROM meihe_list WHERE domain=\'' . get_host($domain) . '\' and `fhy`=\'2\' limit 1');
            }
            if ($rowhy['type'] != 0x1) {
                $gjbq = $conf['tztcgg'];
                if ($rowhy['type'] != 0x1) {
                    $thtime = date('Y-m-d', strtotime('-1 day')) . ' 00:00:00';
                    $meihepvr = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and click_time>=\'' . $thtime . '\'');
                    if ($meihepvr > $conf['day_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 今日访问次数已上限！</h3>');
                        exit(0);
                    }
                    $yesterday_time = date('Y-m-d', strtotime('-1 month')) . ' 00:00:00';
                    $meihepvy = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and and  click_time>=\'' . $yesterday_time . '\'');
                    if ($meihepvy > $conf['month_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 本月访问次数已上限！</h3>');
                        exit(0);
                    } else {
                        if ($rowhy['type'] == 0x2) {
                            sysmsg('<h3>当前网址' . $t_url . ' 已被拉黑无法访问！</h3>');
                            exit(0);
                        } else {
                        }
                    }
                } else {
                }
            } else {
                if ($rowhy['type'] != 0x1) {
                    $thtime = date('Y-m-d', strtotime('-1 day')) . ' 00:00:00';
                    $meihepvr = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and click_time>=\'' . $thtime . '\'');
                    if ($meihepvr > $conf['day_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 今日访问次数已上限！</h3>');
                        exit(0);
                    }
                    $yesterday_time = date('Y-m-d', strtotime('-1 month')) . ' 00:00:00';
                    $meihepvy = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and and  click_time>=\'' . $yesterday_time . '\'');
                    if ($meihepvy > $conf['month_pv']) {
                        sysmsg('<h3>当前网址' . $t_url . ' 本月访问次数已上限！</h3>');
                        exit(0);
                    } else {
                        if ($rowhy['type'] == 0x2) {
                            sysmsg('<h3>当前网址' . $t_url . ' 已被拉黑无法访问！</h3>');
                            exit(0);
                        } else {
                        }
                    }
                } else {
                }
            }
        }
    } else {
        $fhfwfs = 'QQ方式';
        $url_arr = parse_url($t_url);
        $domain = $url_arr['host'];
        $rowhy = $DB->get_row('SELECT * FROM meihe_list WHERE domain=\'' . $domain . '\' limit 1');
        if (empty($rowhy)) {
            $rowhy = $DB->get_row('SELECT * FROM meihe_list WHERE domain=\'' . get_host($domain) . '\' and `fhy`=\'2\' limit 1');
        }
        if ($rowhy['type'] != 0x1) {
            $gjbq = $conf['tztcgg'];
            if ($rowhy['type'] != 0x1) {
                $thtime = date('Y-m-d', strtotime('-1 day')) . ' 00:00:00';
                $meihepvr = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and click_time>=\'' . $thtime . '\'');
                if ($meihepvr > $conf['day_pv']) {
                    sysmsg('<h3>当前网址' . $t_url . ' 今日访问次数已上限！</h3>');
                    exit(0);
                }
                $yesterday_time = date('Y-m-d', strtotime('-1 month')) . ' 00:00:00';
                $meihepvy = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and and  click_time>=\'' . $yesterday_time . '\'');
                if ($meihepvy > $conf['month_pv']) {
                    sysmsg('<h3>当前网址' . $t_url . ' 本月访问次数已上限！</h3>');
                    exit(0);
                } else {
                    if ($rowhy['type'] == 0x2) {
                        sysmsg('<h3>当前网址' . $t_url . ' 已被拉黑无法访问！</h3>');
                        exit(0);
                    } else {
                    }
                }
            } else {
            }
        } else {
            if ($rowhy['type'] != 0x1) {
                $thtime = date('Y-m-d', strtotime('-1 day')) . ' 00:00:00';
                $meihepvr = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and click_time>=\'' . $thtime . '\'');
                if ($meihepvr > $conf['day_pv']) {
                    sysmsg('<h3>当前网址' . $t_url . ' 今日访问次数已上限！</h3>');
                    exit(0);
                }
                $yesterday_time = date('Y-m-d', strtotime('-1 month')) . ' 00:00:00';
                $meihepvy = $DB->count('SELECT count(*) FROM meihe_log where domain=\'' . $domain . '\' and and  click_time>=\'' . $yesterday_time . '\'');
                if ($meihepvy > $conf['month_pv']) {
                    sysmsg('<h3>当前网址' . $t_url . ' 本月访问次数已上限！</h3>');
                    exit(0);
                } else {
                    if ($rowhy['type'] == 0x2) {
                        sysmsg('<h3>当前网址' . $t_url . ' 已被拉黑无法访问！</h3>');
                        exit(0);
                    } else {
                    }
                }
            } else {
            }
        }
    }
    if (!($conf['mffw'] != 0 && $rowhy['type'] != 0x1 && isset($_SESSION['user_login_mail']) && $_SESSION['user_login_mail'] > TIMESTAMP - $conf['mffw'])) {
        $DB->query('insert into `meihe_log` (`domain`,`fwfs`,`time`,`click_time`,`user_agent`,`ip_address`) values (\'' . $domain . '\',\'' . $fhfwfs . '\',\'' . TIMESTAMP . '\',\'' . $date . '\',\'' . $user_agent . '\',\'' . real_ip() . '\')');
        if (!(strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== !1)) {
            if (!(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== !1)) {
                echo '<!DOCTYPE html>
				<html lang="zh">
				<head>
				<title>正在打开网站中</title>
				<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
			</head>
<script>  
self.location.href="';
                echo $t_url;
                echo '"
</script>  
</html>
';
                exit;
            }
            echo '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>';
            echo $title;
            echo '</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="wap-font-scale" content="no">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script type="text/javascript">{js}</script>
<script type="text/javascript" src="../assets/plugin/jump/qqapi.js?_bid=152"></script>
<script type="text/javascript" src="../assets/plugin/jump/jquery.min.js"></script>
<script type="text/javascript" src="../assets/plugin/jump/uomg.php?ver={ver}"></script>
<style type="text/css">
@charset "utf-8";html{color:#000;background:#fff;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
html *{outline:0;-webkit-text-size-adjust:none;-webkit-tap-highlight-color:transparent}
body,html{font-family:sans-serif}
a:hover{text-decoration:underline}
a,ins{text-decoration:none}
#app,body,html{width:100%;height:100%;margin:0;padding:0}
.ios-wechat-qq{height:100%;width:100%;position:relative}
.left-22{width:38%;margin-top:2.32rem;float:left}
.right-33{width:38%;margin-right:10px;float:right}
.description-1{font-size:15px;margin-left:5px;margin-top:30%;float:left}
.description-1 .t-1{color:#757575;letter-spacing:0}
.description-1 .t-2{color:#0f0f0f;letter-spacing:0}
.line-1{width:14%;float:right}
.line-2{top:5.33333rem;width:8%;float:left}
.description-2{text-align:center;font-size:15px;margin-left:10px;margin-top:10px;float:right}
.download-area{display:-ms-flexbox;display:flex;-ms-flex-direction:row;width:80%;margin:40% auto auto auto;padding:5%;background:#f9f9f9;border-radius:4px;-ms-flex-align:center;align-items:center}
.download-area .logo{width:15%;margin-right:5%}
.download-area .t-1{text-align:left;font-size:14px;color:#fb7299}
.download-area .t-2{text-align:left;margin-top:.21333rem;font-size:15px;color:#999}
.download-area .button{font-size:14px;color:#fff;width:5rem;height:1.5rem;line-height:1.5rem;text-align:center;background:#fb7299;border-radius:4px;margin-left:auto}
</style>
</head>
<body>
<div id="app">
    <div class="ios-wechat-qq">
        <div style="height: 25%;">
            <img src="../assets/img/HTB1idjsXzzuK1Rjy0Fp761EpFXar.png" alt="" class="left-22">
            <div class="description-1">
                <span class="t-1">若你已经安装了客户端，</span><br>
                <span class="t-2">请点击下方前往</span>
            </div>
            <img src="../assets/img/HTB1JBTqXEvrK1RjSszf760JNVXae.png" alt="" class="line-1">
        </div>
        <div style="height: 25%;">
            <img src="../assets/img/HTB16qvwXvjsK1Rjy1Xa762ispXab.png" alt="" class="line-2">
            <img src="../assets/img/HTB1FrrtXzDuK1Rjy1zj762raFXa7.png" alt="" class="right-33">
            <div class="description-2">或复制到浏览器打开<br>';
            echo $gjbq;
            echo '</div>
        </div>
        <div class="download-area">
            <img src="../assets/img/mtt.png" alt="" class="logo">
            <div>
                <div class="t-1" style="word-break:break-all;">';
            echo $t_url;
            echo '</div>
                <div class="t-2">请复制到浏览器打开～</div>
            </div>
                <a href="mttbrowser://url=';
            echo $t_url;
            echo '" class="button">前往</a>
        </div>
    </div>
    <meta http-equiv="refresh" content="0.1;url=mttbrowser://url=';
            echo $t_url;
            echo '">
</div>
</body>
</html>
';
            exit;
        }
        echo '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>';
        echo $title;
        echo '</title>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="wap-font-scale" content="no">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script type="text/javascript">{js}</script>
<script type="text/javascript" src="../assets/plugin/jump/qqapi.js?_bid=152"></script>
<script type="text/javascript" src="../assets/plugin/jump/jquery.min.js"></script>
<script type="text/javascript" src="../assets/plugin/jump/uomg.php?ver={ver}"></script>
<style type="text/css">
@charset "utf-8";html{color:#000;background:#fff;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
html *{outline:0;-webkit-text-size-adjust:none;-webkit-tap-highlight-color:transparent}
body,html{font-family:sans-serif}
a:hover{text-decoration:underline}
a,ins{text-decoration:none}
#app,body,html{width:100%;height:100%;margin:0;padding:0}
.ios-wechat-qq{height:100%;width:100%;position:relative}
.left-22{width:38%;margin-top:2.32rem;float:left}
.right-33{width:38%;margin-right:10px;float:right}
.description-1{font-size:15px;margin-left:5px;margin-top:30%;float:left}
.description-1 .t-1{color:#757575;letter-spacing:0}
.description-1 .t-2{color:#0f0f0f;letter-spacing:0}
.line-1{width:14%;float:right}
.line-2{top:5.33333rem;width:8%;float:left}
.description-2{text-align:center;font-size:15px;margin-left:10px;margin-top:10px;float:right}
.download-area{display:-ms-flexbox;display:flex;-ms-flex-direction:row;width:80%;margin:40% auto auto auto;padding:5%;background:#f9f9f9;border-radius:4px;-ms-flex-align:center;align-items:center}
.download-area .logo{width:15%;margin-right:5%}
.download-area .t-1{text-align:left;font-size:14px;color:#fb7299}
.download-area .t-2{text-align:left;margin-top:.21333rem;font-size:15px;color:#999}
.download-area .button{font-size:14px;color:#fff;width:5rem;height:1.5rem;line-height:1.5rem;text-align:center;background:#fb7299;border-radius:4px;margin-left:auto}
</style>
</head>
<body>
<div id="app">
    <div class="ios-wechat-qq">
        <div style="height: 25%;">
            <img src="../assets/img/HTB1idjsXzzuK1Rjy0Fp761EpFXar.png" alt="" class="left-22">
            <div class="description-1">
                <span class="t-1">若你已经安装了客户端，</span><br>
                <span class="t-2">请点击下方前往</span>
            </div>
            <img src="../assets/img/HTB1JBTqXEvrK1RjSszf760JNVXae.png" alt="" class="line-1">
        </div>
        <div style="height: 25%;">
            <img src="../assets/img/HTB16qvwXvjsK1Rjy1Xa762ispXab.png" alt="" class="line-2">
            <img src="../assets/img/HTB1FrrtXzDuK1Rjy1zj762raFXa7.png" alt="" class="right-33">
            <div class="description-2">或复制到浏览器打开<br>';
        echo $gjbq;
        echo '</div>
        </div>
        <div class="download-area">
            <img src="../assets/img/mtt.png" alt="" class="logo">
            <div>
                <div class="t-1" style="word-break:break-all;">';
        echo $t_url;
        echo '</div>
                <div class="t-2">请复制到浏览器打开～</div>
            </div>
                <a href="mttbrowser://url=';
        echo $t_url;
        echo '" class="button">前往</a>
        </div>
    </div>
    <meta http-equiv="refresh" content="0.1;url=mttbrowser://url=';
        echo $t_url;
        echo '">
</div>
</body>
</html>
';
        exit;
    }
    sysmsg('<h3>访问频率太高！请等待' . $conf['mffw'] . '秒后再访问！</h3>');
    exit(0);
}
sysmsg('<h3>当前链接不存在，可能没有生成过或已被删记录！</h3>');
exit(0);
